'use strict';
const dayjs = require("dayjs");
module.exports = app => {
    const { INTEGER, STRING, TEXT } = app.Sequelize;
    const News = app.model.define(
      'News',
          {
              id: {type: INTEGER, primaryKey: true, autoIncrement: true},
                title: STRING,
              image: STRING,
              content: TEXT,
              status: INTEGER,
              description: STRING,
              delete_flag: INTEGER,
              created_at: {
                  type: app.Sequelize.DATE,
                  get() {
                      return dayjs(this.getDataValue('created_at')).format('YYYY-MM-DD HH:mm:ss');
                  }
              },
          },
          {
              tableName: 'news',
              timestamps: true, // 启用时间戳(createdAt, updatedAt)
          }
    );
    return News;
};
